Skip to main content

Socket Connection

In order to connect the user and the doctor there should be a channel that reflects the status update of the consultation, So we have the Pusher.

Pusher​

For initiating the socket, you need the pusherChannel and pusherAppKey from the consultation data.

import 'package:altibbi/pusher.dart';

Pusher().init(
onEvent: onEvent,
channelName: consultation.pusherChannel!,
apiKey: consultation.pusherApiKey! // mapped from pusherAppKey in JSON
);

Listen to Events​

Register an onEvent function to handle updates:

void onEvent(event) async {
print("Event Name: ${event.eventName}");
// Example: handle status updates
if (event.eventName == 'call-status') {
// Refresh consultation data
}
}

Configuration Models​

When the consultation status moves to in_progress, the following config objects will be populated:

ChatConfig​

class ChatConfig {
int? id;
int? consultationId;
String? groupId;
String? chatUserId;
String? appId;
String? chatUserToken;
}

VoipConfig (used for both VOIP and Video)​

class VoipConfig {
int? id;
int? consultationId;
String? apiKey;
String? callId;
String? token;
}